/*
Copyright (C) 2010 Martin Zuber, zuber@centrum.cz

This application is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.

This application is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with This application; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

#ifndef FEGGCLOCKWIDGET_H
#define FEGGCLOCKWIDGET_H

#include <QWidget>
#include <QTimer>
#include <QTime>

namespace Ui {
    class FEggClockWidget;
}

class FEggClockWidget : public QWidget
{
    Q_OBJECT

    QTimer *m_timer;    // local timer for decrementing by second
    QTimer *m_alertTimer;   // for alert CSS effects
    bool m_isRunning;   // flag - is the egg clock running
    bool m_isAlert;     // flag - the clock is in alert mode
    QTime m_lastTime;   // last set time before the START was pressed
    bool m_alertStyleSwitch;   // switching alert CSS flag
public:
    explicit FEggClockWidget(QWidget *parent = 0);
    ~FEggClockWidget();

    /**
        stops and resets the counter
        */
    void stopAlertAndReset();

private:
    Ui::FEggClockWidget *ui;
    void loadPresets();

private slots:
    /**
      When the reset button is clicked, the clock counter is set to previous value
      */
    void on_cbPreset_currentIndexChanged(int index);
    void on_pbReset_clicked();

    /**
      Sets clock counter to 00:00:00
      */
    void on_pbClear_clicked();

    /**
      Button START/STOP/SNOOZE was pressed
      */
    void on_pbStart_clicked();

    /**
      Slot for decrementing by second
      */
    void onTimerTimeOut();

    /**
      Slot for alert effects
      */
    void onAlertTimerTimeOut();
};

#endif // FEGGCLOCKWIDGET_H
